package com.xj.service;

import com.xj.dao.TicketDAO;
import com.xj.model.Ticket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TicketService {

  @Autowired
  private TicketDAO ticketDAO;

  /**
   * 添加票据
   * @param t
   */
  public void addTicket(Ticket t){
    ticketDAO.addTicket(t);
  }

  /**
   * 重载方法，根据用户id获取票据
   * @param uid
   * @return
   */
  public Ticket getTicket(int uid){
    return ticketDAO.selectByUserId(uid);
  }

  /**
   * 重载方法，根据票据字符串获取票据
   * @param t
   * @return
   */
  public Ticket getTicket(String t){
    return ticketDAO.selectByTicket(t);
  }

  /**
   * 重载方法，根据票据id删除票据
   * @param tid
   */
  public void deleteTicket(int tid){
    ticketDAO.deleteTicketById(tid);
  }

  /**
   * 重载方法，根据票据字符串删除票据
   * @param t
   */
  public void deleteTicket(String t){
    ticketDAO.deleteTicket(t);
  }
}
